<template>
  <div id="app">
    <h1>模块化{{count}}</h1>
    <button @click="addFn(1)">点我+1</button><br>
    <button @click="addFnAsync(1)">点我异步加载</button><br>
    <h1>getters:{{xxxList}}</h1>

    <input type="text">
      <Son1>
      </Son1>

      <hr>
        <Son2></Son2>

      </div>

</template>

<script>
import { mapActions, mapGetters, mapMutations, mapState } from 'vuex'
import Son1 from './components/Son1.vue'
import Son2 from './components/Son2.vue'

export default {
  name: 'app',
  data: function () {
    return {

    }
  },
  components: {
    Son1,
    Son2
  },
  computed: {
    // 4.mapxxx使用时，第一个参数是模块名
    ...mapState('user', ['count']),
    ...mapGetters('user', ['xxxList'])
  },
  methods: {
    ...mapMutations('user', ['addFn']),
    ...mapActions('user', ['addFnAsync'])
  }

}

</script>

<style>
  #app {
    width: 600px;
    margin: 20px auto;
    border: 3px solid #ccc;
    border-radius: 3px;
    padding: 10px;
  }
</style>
